<?php

use common\CMS;
use yii\helpers\ArrayHelper;

$config = require Yii::getAlias('@common/config/main.php');

// 合并配置信息
foreach (['main', 'frontend'] as $name)
{
    $config = ArrayHelper::merge($config, CMS::globModuleConfig($name, ['common', 'frontend']));
}

$config = ArrayHelper::merge($config, [
    'id' => 'app-cms-frontend',
    'name' => '前台API',
    'basePath' => CMS_ROOT . 'frontend' . DIRECTORY_SEPARATOR,
    'runtimePath' => CMS_ROOT . 'frontend' . DIRECTORY_SEPARATOR . 'runtime',
    'controllerNamespace' => 'frontend\\controllers',
    'defaultRoute'        => 'site/index',
    'modules' => [
    ],
    'components' => [
        'request' => [
            'cookieValidationKey' => 'Djflj3*dfs',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
            ],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '' => 'site/index',
            ],
        ],
    ],
    'bootstrap' => [
        'log',
    ],
    'extensions' => require(CMS_ROOT . 'vendor/yiisoft/extensions.php'),
]);

if (is_file(__DIR__ . '/main-local.php'))
{
    $config = ArrayHelper::merge($config, @require __DIR__ . '/main-local.php');
}

return $config;
